package model

import (
	"gorm.io/gorm"
	"time"
)

type BaseModel struct {
	ID        int32          `gorm:"primarykey;type:int" json:"id"` //为什么使用int32， bigint
	CreatedAt time.Time      `gorm:"column:add_time" json:"-"`
	UpdatedAt time.Time      `gorm:"column:update_time" json:"-"`
	DeletedAt gorm.DeletedAt `json:"-"`
	IsDeleted bool           `json:"-"`
}

type Inventory struct {
	BaseModel
	GoodsID int32 `gorm:"type:int(11);index;not null;default:0;comment:商品id" `
	Stocks  int32 `gorm:"type:int(11);not null;default:0;comment:库存数量"`
	Version int32 `gorm:"type:int(11);not null;default:0;comment:版本号"`
	Freeze  int32 `gorm:"type:int(11);not null;default:0;comment:冻结库存"`
}

// 订单扣减库存记录表
type OrderDeductionInventory struct {
	BaseModel
	OrderSn string `gorm:"type:varchar(100);not null;comment:订单号"`
	GoodsID int32  `gorm:"type:int(11);index;not null;default:0;comment:商品id" `
	Stocks  int32  `gorm:"type:int(11);not null;default:0;comment:库存数量"`
	Status  int8   `gorm:"type:tinyint(1);not null;default:1;comment:1:扣减完成 2:归还库存（扣减失败）"`
}
